Preemptive Type Checking in Dynamically Typed Languages

نویسندگان

  • Neville Grech
  • Julian Rathke
  • Bernd Fischer
چکیده

We describe a type system that identifies potential type errors in dynamically typed languages like Python. The system uses a flow-sensitive static analysis on bytecodes to compute, for every variable and program point, overapproximations of the variable’s present and future use types. If the future use types are not subsumed by the present types, the further program execution may raise a type error, and a narrowing assertion is inserted; if future use and present types are disjoint, it will raise a type error, and a type error assertion is inserted. We prove that the assertions are inserted in optimal locations and thus preempt type errors earlier than dynamic, soft, and gradual typing. We describe the details of our type inference and assertion insertion, and demonstrate the results of an implementation of the system with a number of examples.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

An Algorithm for Checking the Disjointness of Types

We describe an algorithm approximating the following question: Given two types t1 and t2, are there instances (t1) and (t2) denoting a common element? By answering this question we solve a main problem towards a type checking algorithm for non-disjoint types that raises an error just for function calls that cannot be executed successfully for any input arguments. For dynamically typed functiona...

متن کامل

Static type information to improve the IDE features of hybrid dynamically and statically typed languages

The flexibility offered by dynamically typed programming languages has been appropriately used to develop specific scenarios where dynamic adaptability is an important issue. This has made some existing statically typed languages gradually incorporate more dynamic features to their implementations. As a result, there are some programming languages considered hybrid dynamically and statically ty...

متن کامل

Read-Only Execution for Dynamic Languages

Supporting read-only and side effect free execution has been the focus of a large body of work in the area of statically typed programming languages. So far, dynamically typed languages have been poorly addressed despite their increasing presence in the web and multi-language applications. Read-onlyness in dynamically typed languages is difficult to achieve because of the absence of a type chec...

متن کامل

Managing Gradual Typing with Message-Safety in Dart

This paper establishes a notion of message-safe programs as a natural intermediate point between dynamically typed and statically typed Dart programs. Unlike traditional static type checking, the type system in the Dart programming language is unsound by design. The rationale has been that this allows compile-time detection of likely errors and enables code completion in integrated development ...

متن کامل

Adding Dynamic Types to C#

Developers using statically typed languages such as C and Java increasingly have to interoperate with APIs and object models defined in dynamic languages. This impedance mismatch results in code that is difficult to understand, awkward to analyze, and expensive to maintain. In this paper we describe new features in C4.0 that support the safe combination of dynamically and statically typed code ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2013